<?php
//-------------------------------------------------------------------------------------------------------
    require_once($config['jpgraph']['path'] . 'jpgraph.php');
    require_once($config['app_dir'] . '/includes/object.class.php');
    //---------------------------------------------------------------------------------------------------
    abstract class objPlotView  extends objObject implements iErrorHandler, iVisible{
            public $sizex = 0;
            public $sizey = 0;
            public $title = false;
            public $type = 'png';//jpeg, gif, png
            public $is_cached = false;

            protected $_show_logo = true;
            protected $_show_copyrigth = true;

            protected $_graph = false;
            protected $_error_str = array('no error');

        public function __construct($sizex=400, $sizey=300, $cachetime=false) {
            $this->sizex = $sizex;
            $this->sizey = $sizey;

            if( is_int($cachetime) && $cachetime>0 ) {
                 $this->is_cached = true;
                 $this->_graph = new Graph($this->sizex, $this->sizey, 'auto', $cachetime);
                 $this->is_cached = false;
            } else $this->_graph = new Graph($this->sizex, $this->sizey);
        } //constructor
        //-------------------------------------------------------------------------------------
        public function HideLogo($aValue=false) {
            $this->_show_logo = $aValue;
        } //HideLogo

        public function HideCopyright($aValue=false) {
            $this->_show_copyrigth = $aValue;
        } //HideCopyright
        //-------------------------------------------------------------------------------------
        protected function BuildLogo() {
          global $config;
            $this->_graph->SetBackgroundImage($config['app_dir'].'/public_html/images/logo.png', BGIMG_COPY);
        }//BuildLogo

        protected function BuildCopyright() {
            $copyright = new Text('&#169; 2008 Intelli4x.com. All rights reserved.', round($this->sizex/2), $this->sizey-2);
            $copyright->SetFont(FF_VERDANA, FS_NORMAL, 6.8);
            $copyright->SetAlign('center','bottom');
            $this->_graph->AddText($copyright);
        } //BuildCopyright

        protected function BuildTitle() {
            $this->_graph->title->SetFont(FF_VERDANA, FS_BOLD,16);
            if ( $this->title )  {
            	$this->_graph->title->SetMargin(15);
                $this->_graph->title->Set(strtoupper($this->title));
            }
        } //BuildTitle
        //-------------------------------------------------------------------------------------
        public function ClassName() {
            return  __CLASS__;
        }//ClassName

        abstract protected function BuildGraph();

        public function Render($filename='', $template=false) {
            if( !$this->BuildGraph() ) return false;
            $this->_graph->Stroke($filename);
        } //Render

        public function Fetch() {
            if( !$this->BuildGraph() ) return false;
            return $this->_graph->Stroke(__handle);
        } //Fetch

    }//class PlotView
//-------------------------------------------------------------------------------------------------------
?>
